package com.mz.ieann.dokit.utils

import android.content.Context
import android.os.Build
import java.util.*

/**
 * <p>------------------------------------------------------
 * <p> Copyright (C) 2021 zhangmz, All rights reserved.
 * <p> If there is technical discussion, you can contact zhangmz90@foxmail.com
 * <p>------------------------------------------------------
 * <p> 去本地不同string文件修改语言
 * <p>
 *
 * @author Created by zhangmz
 * @date on 2022/2/17
 */
object LanguageUtil {

    fun changeLanguage(context: Context?, l: Locale): Context?{
        return context?.apply {
            val config = resources.configuration
            config.setLocale(l)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
                createConfigurationContext(config)
            }else {
                val metrics = resources.displayMetrics
                resources.updateConfiguration(config, metrics)
            }
        }
    }

}